﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

public partial class POS_ProductEdit : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void btnSearch_Click(object sender, EventArgs e)
    {
        if (txtBarcode.Text.Trim() != "")
        {
            string sql = @"SELECT [Pos_ProductID]
      ,[ProductID]
      ,[ReferenceID]
      ,[Pos_ProductTypeID]
      ,[Inv_UtilizationDetailsIDs]
      ,[ProductStatusID]
      ,[ProductName]
      ,[DesignCode]
      ,[Pos_SizeID]
      ,[Pos_BrandID]
      ,[Inv_QuantityUnitID]
      ,[FabricsCost]
      ,[AccesoriesCost]
      ,[Overhead]
      ,[OthersCost]
      ,[PurchasePrice]
      ,[SalePrice]
      ,[OldSalePrice]
      ,[Note]
      ,[BarCode]
      ,[Pos_ColorID]
      ,[Pos_FabricsTypeID]
      ,[StyleCode]
      ,[Pic1]
      ,[Pic2]
      ,[Pic3]
      ,[VatPercentage]
      ,[IsVatExclusive]
      ,[DiscountPercentage]
      ,[DiscountAmount]
      ,[FabricsNo]
      ,[ExtraField1]
      ,[ExtraField2]
      ,[ExtraField3]
      ,[ExtraField4]
      ,[ExtraField5]
      ,[ExtraField6]
      ,[ExtraField7]
      ,[ExtraField8]
      ,[ExtraField9]
      ,[ExtraField10]
      ,[AddedBy]
      ,[AddedDate]
      ,[UpdatedBy]
      ,[UpdatedDate]
      ,[RowStatusID]
  FROM [Pos_Product]
where BarCode='"+txtBarcode.Text.Trim()+@"'
";

            DataSet ds = CommonManager.SQLExec(sql);
            
            if (ds.Tables[0].Rows.Count > 0)
            { 
                chkImposed.Checked= bool.Parse(ds.Tables[0].Rows[0]["IsVatExclusive"].ToString());
            }
        }
    }
    protected void btnSave_Click(object sender, EventArgs e)
    {
        string sql = @"Update [Pos_Product] set IsVatExclusive="+(chkImposed.Checked ?"1":"0")+@"
            where BarCode='" + txtBarcode.Text.Trim() + @"'";

        CommonManager.SQLExec(sql);
        lblMessage.Text = "Updated Successfully";
    }
}